//sort里面的函数如果返回值为负数，就以升序排序，否则以降序排序
var score = [90, 58, 89, 57, 12, 55, 68]
score.sort(function (a, b) {
    return a - b
})

var stus = [
    { stuNum: 1101, name: '曹操', score: 95 },
    { stuNum: 1102, name: '吕布', score: 50 },
    { stuNum: 1103, name: '貂蝉', score: 65 },
    { stuNum: 1104, name: '赵云', score: 70 }
];

// var obj = {stuNum: 1101, name: '曹操', score: 95},
// var s = obj.score
//确定对象排序的键
stus.sort(function (a, b) {
    return a.score - b.score
})

var fruits = ["Apple", "Banana", "Angular", "Orange"];
fruits.sort(function (a, b) {

    return b.localeCompare(a)
    // if (a > b) {
    //     return -1
    // } else {
    //     return 1
    // }
})
var names = ['张三', '李磊', '周二哇']
names.sort(function (a, b) {
    return a.localeCompare(b)
})

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var arr1 = arr.filter(function (item, index, arr) {
    return item % 2 == 1
})

var okStuts = stus.filter(function (item) {
    return item.score >= 60
})

var okStut = stus.find(function (item, index, arr) {
    return item.score >= 60
})

var okStutIndex = stus.findIndex(function (item, index, arr) {
    return item.score >= 60
})

// z = 1 + 2 + 3 + 4
// x = 1 + 2
// y = x + 3
// z = y + 4
var arr = [1, 2, 3, 5, 4];
// var res = arr.sort().reverse().map(function(item){
//     return item * 2;
// });

var r1 = arr.sort()
var r2 = r1.reverse()
var res = r2.map(function (item) {
    return item * 2;
});